#include "wlog.h"

const char* func()
{
	LOG_INFO("fun called!!!!!!!!");
	return "func";
}

class Foo {
public:
	Foo()
	{
		LOG_INFO("Foo called!!!!!!!!");
	}

	void func(int b)
	{
		LOG_DEBUG("Foo::func called!!!!!!!!");
	}
};

int main(int argc, char** argv)
{
	wlog::enable_level_switch();

	if (wlog::init_from_file("log.ini") < 0) {
		return -1;
	}

	//wlog::init("logs/run.log", LOG_LEVEL_TRACE, 100, 2);

	// for debug
	printf("alevel: %d\n", SPDLOG_ACTIVE_LEVEL);
	printf("glevel: %d\n", spdlog::get_level());
	printf("wlevel: %d\n", wlog::get_level());

	// Compile time log levels
	LOG_TRACE("Some trace message with param {}", 11);
	LOG_DEBUG("Some debug message a");
	LOG_INFO("Some info message a");

	//wlog::set_level(LOG_LEVEL_INFO);
	//getchar();

	std::string cmd = "killall -s SIGUSR1 ";
	cmd += argv[0];
	system(cmd.c_str());

	printf("wlevel: %d\n", wlog::get_level());

	LOG_TRACE("Some trace message with param {}", 22);
	LOG_DEBUG("Some debug message");
	LOG_INFO("Some info message");
	LOG_DEBUG(func()); // no func call if level is higher than LOG_LEVEL_DEBUG
	LOG_ERROR("Some error message");
	LOG_FATAL("Some critical message");

	char buf[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0x10, 0x11, 0x12, 0x13, 0x14, 0x00, 0x01, 0x12};

	//LOG_HEXDUMP(spdlog::level::info, buf, sizeof(buf), "buf size: {}", sizeof(buf));
	//LOG_HEXDUMP(spdlog::level::info, buf, sizeof(buf), "hex dump ");
	LOG_HEXDUMP(LOG_LEVEL_INFO, buf, sizeof(buf), "buf size: {}", sizeof(buf));
	LOG_HEXDUMP(LOG_LEVEL_INFO, buf, sizeof(buf), "hex dump ");

	Foo foo;
	foo.func(0);

	return 0;
}
